<?php
/**
 * @copyright meila.com
 * @author wangtao5@
 * @name 
 * @param 
 *         $xxx = 作用
 * @static 
 *         XXX = 作用
 * 
 * 
 */

class ml_tool_lbPic2url
{
    static function pid2url($pid,  $sizetype = 'original_pic', $type = '') {
        //zone
        $hv = crc32($pid);
        $zone = ($hv & 3) + 1;

        //type
        if($type == '' && !$type = self::pid2type($pid)) {
            return false;
        }
        $sizetype = substr($sizetype, 0, 2);

        //后缀
        $a = array( 'g'=>'gif', 'j'=>'jpg', 'p'=>'png');
        if (array_key_exists($pid[18], $a)) {
            $ext = $a[$pid[18]];
        }else {
            return false;
        }
        return "http://sinastorage.com/image.meila.com/{$type}/{$pid}_{$sizetype}.{$ext}";
    }

    static function pid2type($pid36) {
        $a = substr ($pid36, 0 ,9 );
        $pid1st = base_convert($a, 36, 10);
        $b = substr ($pid1st, 0, 2);
        $config = array(
                '51' => 'header',
                '32'=>'lmphoto',
                '21'=> 'lmcover',
                '10' => 'lmindex' ,
                '13'=>'lmmark',

                    );
        return $config[$b];
    }
}
?>